<?php ob_start();?>
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
include($root.'/standart/head.php');
include($root.'/standart/dateHeader.php');
include($root.'/standart/checkUser.php');
$db = connect();
$bgn_date = "";
$end_date = "";
$tmpDate = $_GET["begin_date"];
if($tmpDate <> ""){
	list($gun,$ay,$yil) = explode('/',$tmpDate);
	$bgn_date = $yil.'-'.$ay.'-'.$gun;
}
$tmpDate = $_GET["end_date"];
if($tmpDate <> ""){
	list($gun,$ay,$yil) = explode('/',$tmpDate);
	$end_date = $yil.'-'.$ay.'-'.$gun;
}
$userId = $_GET["user_id"];
$stmt ="SELECT ORDERS.ID,GEVEZE_USER.NAME,GEVEZE_USER.SURNAME,ORDERS.ORDER_DATE, CANCEL, 
ORDERS.PAYMENT_TYPE,ADDRESS.ADDRESS_1,ORDERS.NOTES,ORDERS.TOTAL_AMOUNT, ORDERS.ISPRINT FROM ORDERS
LEFT OUTER JOIN GEVEZE_USER ON
ORDERS.USER_ID=GEVEZE_USER.ID
LEFT OUTER JOIN ADDRESS ON
ORDERS.SHIPPING_ADDRESS=ADDRESS.ID WHERE ORDERS.ID IS NOT NULL and ORDER_DATE > CURRENT_TIMESTAMP()";
		
$res = $db->query($stmt) or die($stmt."<br/><br/>".mysql_error());
	?>
	<table class="table table-striped table-bordered table-hover" id="dataTables-example">
		<thead>
        	<tr>        		
                <th>Sipariş No</th>
                <th>İsim Soyisim</th>
                <th>Sipariş Tarihi</th>
				<th>Ödeme Tipi</th>
                <th>Gönderim Adresi</th>
                <th>Sipariş Notu</th>
                <th>Sipariş Tutarı</th>
                <th>İPTAL</th>
                <th>Basıldı mı?</th>
                <th>Sipariş Basma</th>
            </tr>
		</thead>
        <tbody>
        <?php $odd = true; ?>
       	<?php while($row = $res->fetch_assoc()){?>
        	<tr class="<?php echo $odd ? "odd" : "even";?> " style="cursor: pointer;">
	            <td><?php echo $row["ID"];?></td>
	            <td><?php echo $row["NAME"].' '.$row["SURNAME"];?></td>
                <td><?php echo date("m/d/Y H:i",strtotime($row["ORDER_DATE"]));?></td>
                <td><?php echo $row["PAYMENT_TYPE"];?></td>
                <td><?php echo $row["ADDRESS_1"];?></td>
                <td><?php echo $row["NOTES"];?></td>
                 <td style="text-align: right;"><?php echo $row["TOTAL_AMOUNT"]; ECHO ' TL';?></td>
                <td><?php echo ($row["CANCEL"] == '0'? 'Hayır' : 'Evet');?></td>
                <td><?php echo ($row["ISPRINT"] == '0'? 'Hayır' : 'Evet');?></td>
                <td><?php if($row["ISPRINT"]=='1'){?> <input type="button" value="Tekrar Yazdır" onclick="updateIsPrint('<?php echo $row["ID"];?>');">  <?php }?></td>               
			</tr>
			<?php $odd = !$odd;?>
		<?php }?>
			<tfoot>
	            <tr>
 	                <th colspan="6" style="text-align:right">Toplam:</th>
	                <th style="text-align: right;"></th>
	                <th colspan="3"></th>
	            </tr>
	            <tr>
	                <th colspan="8" style="text-align:right">Genel Toplam:</th>
	                <th style="text-align: right;" id="genelToplam"></th>
	                <th></th>
	            </tr>
	        </tfoot>
		</tbody>
     </table>
	<?php 
$res->close();
disconnect($db);
?>
<?php ob_end_flush(); ?>